using FluentNHibernate.AutoMap;
using Webshop20.Domain.Common;
using Webshop20.Domain.Orders.Core;
using Tools.Domain.Common.StateMachine;
using Webshop20.Infrastructure.Persistence.NH.AutoMappings.Conventions.Common;

namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings
{
    public class  ForOrders
    {
        public static AutoPersistenceModel GetPersistenceModel()
        {
            return
                AutoPersistenceModel.MapEntitiesFromAssemblyOf<Order>()
                    .Where(
                            x => (x.Namespace == "Webshop20.Domain.Orders.Core" && !x.Name.EndsWith("Adress") && !x.Name.EndsWith("ConstraintSet"))
                                || x.Namespace == "Webshop20.Domain.Orders.Processes"
                            
                            
                          )
                    .ConventionDiscovery.AddFromAssemblyOf<IdConvention>()
                    .WithSetup(
                                convention =>
                                {
                                    convention.IsBaseType = bt => bt == typeof(Entity);
                                    convention.IsComponentType = ct => ct.Name.EndsWith("Adress");
                                    
                                });
        }
    }
}